package gui.other;

import javax.swing.*;
import java.awt.*;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Date: Feb 9, 2010
 * Time: 11:50:18 PM
 *
 * @author Jose Martin Rozanec;
 * @author Maria Julia Racca;
 */
public class JComponentCellRendererStringContextForString {
    private Color backgroundColorTrue;
    private Color backgroundColorFalse;
    private String value;

    /**
     * Constructor;
     *
     * @param value       - valor de String que se compara con el valor de celda;
     * @param colorTrue;
     * @param colorFalse;
     */
    public JComponentCellRendererStringContextForString(String value, Color colorTrue, Color colorFalse) {
        backgroundColorTrue = colorTrue;
        backgroundColorFalse = colorFalse;
        this.value = value;
    }

    /**
     * Devuelve el componente de la celda;
     *
     * @param table;
     * @param value;
     * @param isSelected;
     * @param hasFocus;
     * @param row;
     * @param column;
     * @return JComponent - componente de la celda;
     */
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if (value != null) {
            String text = (String) value;
            if (text.equals(this.value)) {
//                setBackground(backgroundColorTrue);
            } else {
//                setBackground(backgroundColorFalse);
            }
            table.revalidate();
        }
        return (JComponent) value;
    }
}
